// ICoder.h

#ifndef __ICODER_H
#define __ICODER_H

#include "Common/Stream/IStream.h"

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400040000")
ICompressProgressInfo: public IUnknown
{
  STDMETHOD(SetRatioInfo)(const UINT64 *inSize, const UINT64 *outSize) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400050000")
ICompressCoder: public IUnknown
{
  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UINT64 *inSize, const UINT64 *outSize,
      ICompressProgressInfo *progress) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400180000")
ICompressCoder2: public IUnknown
{
  STDMETHOD(Code)(ISequentialInStream **inStreams, const UINT64 **inSizes, UINT32 numInStreams,
      ISequentialOutStream **outStreams, const UINT64 **outSizes, UINT32 numOutStreams,
      ICompressProgressInfo *progress) PURE;
};

namespace Common
{
namespace Interfaces
{
  enum class CoderPropID
  {
    kDefaultProp = 0,
    kDictionarySize,
    kUsedMemorySize,
    kOrder,
    kBlockSize,
    kPosStateBits,
    kLitContextBits,
    kLitPosBits,
    kNumFastBytes,
    kMatchFinder,
    kMatchFinderCycles,
    kNumPasses,
    kAlgorithm,
    kNumThreads,
    kEndMarker
  };

}
}

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400200000")
ICompressSetCoderProperties: public IUnknown
{
  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UINT32 numProps) PURE;
};

/*
DEFFINE_GUID_7ZIP(ICompressSetCoderProperties, 4, 0x21) 
struct ICompressSetCoderProperties: public IUnknown
{
  STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
};
*/

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400220000")
ICompressSetDecoderProperties2: public IUnknown
{
  STDMETHOD(SetDecoderProperties2)(const BYTE *data, UINT32 size) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400230000")
ICompressWriteCoderProperties: public IUnknown
{
  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400240000")
ICompressGetInStreamProcessedSize: public IUnknown
{
  STDMETHOD(GetInStreamProcessedSize)(UINT64 *value) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400250000")
ICompressSetCoderMt: public IUnknown
{
  STDMETHOD(SetNumberOfThreads)(UINT32 numThreads) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400300000")
ICompressGetSubStreamSize: public IUnknown
{
  STDMETHOD(GetSubStreamSize)(UINT64 subStream, UINT64 *value) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400310000")
ICompressSetInStream: public IUnknown
{
  STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
  STDMETHOD(ReleaseInStream)() PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400320000")
ICompressSetOutStream: public IUnknown
{
  STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
  STDMETHOD(ReleaseOutStream)() PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400330000")
ICompressSetInStreamSize: public IUnknown
{
  STDMETHOD(SetInStreamSize)(const UINT64 *inSize) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400340000")
ICompressSetOutStreamSize: public IUnknown
{
  STDMETHOD(SetOutStreamSize)(const UINT64 *outSize) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400350000")
ICompressSetBufSize: public IUnknown
{
  STDMETHOD(SetInBufSize)(UINT32 streamIndex, UINT32 size) PURE;
  STDMETHOD(SetOutBufSize)(UINT32 streamIndex, UINT32 size) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400400000")
ICompressFilter: public IUnknown
{
  STDMETHOD(Init)() PURE;
  STDMETHOD_(UINT32, Filter)(BYTE *data, UINT32 size) PURE;
  // Filter converts as most as possible bytes
  // Filter return outSize (UINT32)
  // if (outSize <= size): Filter have converted outSize bytes
  // if (outSize > size): Filter have not converted anything.
  //      and it needs at least outSize bytes to convert one block
  //      (it's for crypto block algorithms).
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400600000")
ICompressCodecsInfo: public IUnknown
{
  STDMETHOD(GetNumberOfMethods)(UINT32 *numMethods) PURE;
  STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value) PURE;
  STDMETHOD(CreateDecoder)(UINT32 index, const GUID *iid, void **coder) PURE;
  STDMETHOD(CreateEncoder)(UINT32 index, const GUID *iid, void **coder) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400610000")
ISetCompressCodecsInfo: public IUnknown
{
  STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400800000")
ICryptoProperties: public IUnknown
{
  STDMETHOD(SetKey)(const BYTE *data, UINT32 size) PURE;
  STDMETHOD(SetInitVector)(const BYTE *data, UINT32 size) PURE;
};

/*
CODER_INTERFACE(ICryptoResetSalt, 0x88)
{
  STDMETHOD(ResetSalt)() PURE;
};
*/

MIDL_INTERFACE("23170F69-40C1-278A-0000-0004008C0000")
ICryptoResetInitVector: public IUnknown
{
  STDMETHOD(ResetInitVector)() PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400900000")
ICryptoSetPassword: public IUnknown
{
  STDMETHOD(CryptoSetPassword)(const BYTE *data, UINT32 size) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000400A00000")
ICryptoSetCRC: public IUnknown
{
  STDMETHOD(CryptoSetCRC)(UINT32 crc) PURE;
};

//////////////////////
// It's for DLL file
namespace MethodPropID
{
  enum EEnum
  {
    kID,
    kName,
    kDecoder,
    kEncoder,
    kInStreams,
    kOutStreams,
    kDescription,
    kDecoderIsAssigned,
    kEncoderIsAssigned
  };
}

#endif
